<template>
  <div @click="goCounselor">跳转绑定顾问页</div>
</template>

<script>

function parseUrlParams(url) {
  const paramsObj = {};
  const queryString = url.split('?')[1];
  if (queryString) {
    const paramPairs = queryString.split('&');
    paramPairs.forEach(paramPair => {
      const [key, value] = paramPair.split('=');
      paramsObj[key] = value ? decodeURIComponent(value) : '';
    });
  }
  return paramsObj;
}


	export default {
		data() {
			return {
			}
		},
		onLoad(options) {
      // 例子： q: "https%3A%2F%2Fstatic.bsyjk.cn%2Fcheck%2Ftj%3Fa%3D123", scancode_time: "1711092894"
      const q = options.q;
      const url = decodeURIComponent(q);
      const params = parseUrlParams(url);
      this.params = params;
			console.warn('onLoad', options, params)
      //如果当前用户已经登录了 跳转这个界面
			if(global.token){
				this.goCounselor(params); //获取评估信息
			}else{
				this.$urouter.redirectTo({
					url: '/pages/signIn/signIn',
					params: {
						jumpInterface:'/check/counselor',
						transferParameters:JSON.stringify(params)
					}
				});
			}
		},
		onShow(options) {
			console.warn('onSHow', options)
		},
    methods: {  
      goCounselor(params) {
        this.$urouter.redirectTo({
          url: '/check/counselor',
          params
        })
      }
    }
  }
  </script>